import {createRouter, createWebHistory} from "vue-router";
import Home from "../views/Home.vue";

const routes = [
    {
        path: '/',
        redirect: '/index'
    }, {
        path: "/",
        name: "Home",
        component: Home,
        children: [
            {
                path: "/index",
                name: "index",
                meta: {
                    title: '首页'
                },
                component: () => import (
                /* webpackChunkName: "index" */
                "../views/index.vue")
            }, {
                path: "/lhyg",
                name: "lhyg",
                meta: {
                    title: '灵活用工平台'
                },
                component: () => import (
                /* webpackChunkName: "lhyg" */
                "../views/lhyg.vue")
            }, {
                path: "/business",
                name: "business",
                meta: {
                    title: '企业信息'
                },
                component: () => import (
                /* webpackChunkName: "tabs" */
                "../views/business.vue")
            }, {
                path: "/service",
                name: "service",
                meta: {
                    title: '服务者信息'
                },
                component: () => import (
                /* webpackChunkName: "service" */
                "../views/service.vue")
            }, {
                path: "/Individual",
                name: "Individual",
                meta: {
                    title: '个体工商户信息'
                },
                component: () => import (
                /* webpackChunkName: "Individual" */
                "../views/Individual.vue")
            }, {
                path: "/assignment",
                name: "assignment",
                meta: {
                    title: '任务信息',
                },
                component: () => import (
                /* webpackChunkName: "assignment" */
                "../views/assignment.vue")
            }, {
                path: "/project",
                name: "project",
                meta: {
                    title: '项目管理',
                },
                component: () => import (
                /* webpackChunkName: "project" */
                "../views/project.vue")
            }, {
                path: "/settlement",
                name: "settlement",
                meta: {
                    title: '结算信息'
                },
                component: () => import (
                /* webpackChunkName: "settlement" */
                "../views/settlement.vue")
            }, {
                path: "/settlements",
                name: "settlements",
                meta: {
                    title: '无感发薪结算单'
                },
                component: () => import (
                /* webpackChunkName: "settlements" */
                "../views/settlements.vue")
            }, {
                path: "/invoice",
                name: "invoice",
                meta: {
                    title: '发票信息'
                },
                component: () => import (
                /* webpackChunkName: "invoice" */
                "../views/invoice.vue")
            }, {
                path: "/lhygDel",
                name: "lhygDel",
                meta: {
                    title: '灵活用工详情'
                },
                component: () => import (
                /* webpackChunkName: "lhygDel" */
                "../views/lhygDel.vue")
            }, {
                path: '/businessDel',
                name: 'businessDel',
                meta: {
                    title: '企业信息详情'
                },
                component: () => import (/* webpackChunkName: "businessDel" */
                '../views/businessDel.vue')
            }, {
                path: '/assignmentDel',
                name: 'assignmentDel',
                meta: {
                    title: '任务信息详情'
                },
                component: () => import (/* webpackChunkName: "assignmentDel" */
                '../views/assignmentDel.vue')
            }, {
                path: '/serviceDel',
                name: 'serviceDel',
                meta: {
                    title: '服务者信息详情'
                },
                component: () => import (/* webpackChunkName: "serviceDel" */
                '../views/serviceDel.vue')
            }, {
                path: '/settlementDel',
                name: 'settlementDel',
                meta: {
                    title: '结算信息详情'
                },
                component: () => import (/* webpackChunkName: "settlementDel" */
                '../views/settlementDel.vue')
            }, {
                path: '/settlementDels',
                name: 'settlementDels',
                meta: {
                    title: '无感发薪结算单详情'
                },
                component: () => import (/* webpackChunkName: "settlementDels" */
                '../views/settlementDels.vue')
            }, {
                path: '/invoiceDel',
                name: 'invoiceDel',
                meta: {
                    title: '发票信息详情'
                },
                component: () => import (/* webpackChunkName: "invoiceDel" */
                '../views/invoiceDel.vue')
            }, {
                path: '/IndividualDel',
                name: 'IndividualDel',
                meta: {
                    title: '个体工商户信息详情'
                },
                component: () => import (/* webpackChunkName: "IndividualDel" */
                '../views/IndividualDel.vue')
            }, {
                path: '/personal',
                name: 'personal',
                meta: {
                    title: '个体户办理'
                },
                component: () => import (/* webpackChunkName: "personal" */
                '../views/personal.vue')
            }, {
                path: "/Icon",
                name: "basecharts",
                meta: {
                    title: '图表'
                },
                component: () => import (
                /* webpackChunkName: "charts" */
                "../views/BaseCharts.vue")
            }, {
                path: '/403',
                name: '403',
                meta: {
                    title: '没有权限'
                },
                component: () => import (/* webpackChunkName: "403" */
                '../views/403.vue')
            }, {
                path: '/accountManagement',
                name: 'accountManagement',
                meta: {
                    title: '账号管理'
                },
                component: () => import (
                /* webpackChunkName: "accountManagement" */
                '../views/accountManagement.vue')
            }, {
                path: '/establishAccount',
                name: 'establishAccount',
                meta: {
                    title: '账号'
                },
                component: () => import (
                /* webpackChunkName: "accountManagement" */
                '../views/establishAccount.vue')
            },
        ]
    }, {
        path: "/login",
        name: "Login",
        meta: {
            title: '登录'
        },
        component: () => import (
        /* webpackChunkName: "login" */
        "../views/Login.vue")
    }, {
        path: "/:pathMatch(.*)*",
		meta: {
			title: '404页面不存在'
		},
        component: () => import (
        /* webpackChunkName: "login" */
        "../views/404.vue")
    }
];

const router = createRouter({
    history: createWebHistory(),
    routes
});

// router.beforeEach((to, from, next) => {
//     document.title = `${to.meta.title}`;
//     const role = localStorage.getItem('hegui_token');
//     if (!role && to.path !== '/login') {
//         next('/login');
//     } else if (to.meta.permission) {
//         // 如果是管理员权限则可进入，这里只是简单的模拟管理员权限而已
//         role === 'admin'
//             ? next()
//             : next('/403');
//     } else {
//         next();
//     }
// });

export default router;